/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dispositivos;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.logging.Logger;
/**
 * 
 * @author 66880717
 */
public class Fichero implements Dispositivo{
    
    @Override
    public String leer(String... ruta) {
        String resultado = "";
        try {
            BufferedReader br = new BufferedReader( new InputStreamReader (new FileInputStream (ruta[0])));
            String line;
            
            while ((line = br.readLine())!=null) {
                resultado += line;
            }
            
                
            } catch (IOException ex) {                
               ex.printStackTrace(System.err);
            }
        return resultado;
            
        
        }
          
  public void escribir (String contenido, String... ruta) {
    
        try {
            BufferedWriter br = new BufferedWriter( new OutputStreamWriter (new FileOutputStream (ruta[0])));
            br.write(contenido);
                
            } catch (IOException ex) {                
               ex.printStackTrace(System.err);
            }
       
            
        
 }   
        
      
    }
